﻿using System.Data;

namespace SimpleExpression
{
    public class SqlSelectPlan : QueryPlanSQL
    {
        private ISqlSelectCommandStrategy strategy;

        //Convenient method
        public SqlSelectPlan(EntityExpression entityExpression)
            :this(entityExpression, new SqlServerSelectCommandStrategy())
        { 
        
        }

        public SqlSelectPlan(EntityExpression entityExpression, ISqlSelectCommandStrategy strategy)
        {
            this.EntityExpression = entityExpression;
            this.strategy = strategy;
            this.ExpressionVisitor = new SelectVisitorSQL(this.strategy);
        }

        public override void GetResult()
        {
            base.GetResult();

            this.command = (IDbCommand)this.strategy.Command;
        }
    }
}